package cn.acewill.yxd.yunxundian.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;

import cn.acewill.yxd.yunxundian.R;
import cn.acewill.yxd.yunxundian.model.EmailBean;


/**
 * Created by XXX on 2017/4/3.
 */
public class EmailAdpater extends BaseAdapter{

    private Context context;
    private ArrayList<EmailBean> list;

    public EmailAdpater(Context context,ArrayList<EmailBean> list){
        this.context=context;
        this.list=list;
    }
    @Override
    public int getCount() {
        return list==null?0:list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if(convertView==null){
            convertView= LayoutInflater.from(context).inflate(R.layout.emailinfo,parent,false);
            holder=new ViewHolder();
            holder.EuserName= (TextView) convertView.findViewById(R.id.EuserName);
            holder.EmailAddress= (TextView) convertView.findViewById(R.id.EmailAddress);
            convertView.setTag(holder);
        }else{
            holder= (ViewHolder) convertView.getTag();
        }
        EmailBean bean=list.get(position);
        holder.EuserName.setText(bean.getMailName());
        holder.EmailAddress.setText(bean.getMailAddress());
        return convertView;
    }
    class ViewHolder{
        TextView EuserName;
        TextView EmailAddress;
    }
}
